﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Services;
using Dala.Samples.BusinessLogicLayer;
using Dala.Samples.DataAccessLayer;
using Dala.Utilities;

namespace Dala.Samples.Google_Map_Example
{
    public partial class google_map : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
                ucBreadCrumb.BindBreadCrumb();
        }

        [WebMethod]
        public static List<Location> GetAllLocation()
        {
            List<Location> _location = new LocationBLL().GetAllLocations().ToList();
            
            for(int i=0;i <_location.Count;i++)
            {
                string address = _location[i].Address + ", " + _location[i].City + ", " + _location[i].State + " " + _location[i].ZipCode;
                Coordinate _co = new Coordinate();
                _co = Geocode.GetCoordinates(address);
                _location[i].Latitude = _co.Latitude.ToString();
                _location[i].Longitude = _co.Longitude.ToString();
            }

            return _location;
        }
    }
}   